****TESTS FREE-RIDING USING THE SHARE OF A SUBJECT-GRADE THAT A TEACHER TEACHES AS THE MEASURE OF HOW MUCH OF AN AWARD THEY'RE RESPONSIBLE FOR***

  *OPEN STUDENT LEVEL FILE*
clear all
set mem 3g
set more off
cap log close
log using teacher_share.log, replace
set seed 7563543


cd "C:\teacher free riding"
use hisd_data_freeriding_b.dta, clear

sort campus year grade

**IDENTIFY THE MAXIMUM AWARD FOR A TEACHER
gen maxaward = 0
replace maxaward = 5000 if year == 2006 | year == 2007
replace maxaward = 7000 if year == 2008 | year == 2009

gen post = year >= 2006
drop if id == .
xtset id year

drop unit
gen unit = 1
egen enroll = sum(unit), by(campus year)
gen enroll2 = enroll^2
gen enroll3 = enroll^3
gen enroll4 = enroll^4

***NOTE THAT 9TH GRADE SCIENCE AND SOC ARE STANFORD RATHER THAN TAKS IN ASPIRE****
***FOR INITIAL ANALYSIS DO ONLY MATH & READING FOR ALL GRADES (TAKS) AND LANGUAGE FOR ALL GRADES (STANF)****
***SCIENCE & SOC FOR 10 & 11.FOR ACROSS DEPARTMENT ANALYSIS, LIMIT TO GRADES 10 & 11****


*ACHIEVEMENT LAGS
foreach subject in "math" "read" {
  gen ltaks_sd_scale_min_`subject' = l.taks_sd_scale_min_`subject'
 }
foreach subject in "math" "read" "lang" "socialstu" "science" {
  gen lstanford_sd_`subject'_scale = l.stanford_sd_`subject'_scale
 }

*NO SCIENCE & SOC IN 10TH GRADE SO USE 8TH GRADE LAG
foreach subject in "sci" "soc" {
  gen ltaks_sd_scale_min_`subject' = 0 if grade == 10 | grade == 11
  replace ltaks_sd_scale_min_`subject' = l.taks_sd_scale_min_`subject' if grade == 11
  gen l2taks_sd_scale_min_`subject' = 0 if grade == 10 | grade == 11
  replace l2taks_sd_scale_min_`subject' = l2.taks_sd_scale_min_`subject' if grade == 10
 }
 
 
 *GENERATE PRE-LAGS FROM 2004 - for 2004 and earlier use once lagged score
 foreach subject in "math" "read" {
 	gen taks_`subject'_2004 = l.taks_sd_scale_min_`subject'
	replace taks_`subject'_2004 = l3.taks_sd_scale_min_`subject' if year == 2007
	replace taks_`subject'_2004 = l4.taks_sd_scale_min_`subject' if year == 2008
	replace taks_`subject'_2004 = l5.taks_sd_scale_min_`subject' if year == 2009
}

 foreach subject in "math" "read" "lang" "science" "socialstu" {
 	gen stanf_`subject'_2004 = l.stanford_sd_`subject'_scale
	replace stanf_`subject'_2004 = l3.stanford_sd_`subject'_scale if year == 2007
	replace stanf_`subject'_2004 = l4.stanford_sd_`subject'_scale if year == 2008
	replace stanf_`subject'_2004 = l5.stanford_sd_`subject'_scale if year == 2009
}

 *GENERATE PRE-LAGS FROM 2003 - for2003 and earlier use once lagged score
 foreach subject in "math" "read" {
 	gen taks_`subject'_2003 = l.taks_sd_scale_min_`subject'
	replace taks_`subject'_2003 = l4.taks_sd_scale_min_`subject' if year == 2007
	replace taks_`subject'_2003 = l5.taks_sd_scale_min_`subject' if year == 2008
	replace taks_`subject'_2003 = l6.taks_sd_scale_min_`subject' if year == 2009
}

 foreach subject in "math" "read" "lang" "science" "socialstu" {
 	gen stanf_`subject'_2003 = l.stanford_sd_`subject'_scale
	replace stanf_`subject'_2003 = l4.stanford_sd_`subject'_scale if year == 2007
	replace stanf_`subject'_2003 = l5.stanford_sd_`subject'_scale if year == 2008
	replace stanf_`subject'_2003 = l6.stanford_sd_`subject'_scale if year == 2009
}

*GENERATE 2004 TEST SCORES FOR ALL YEARS FOR ACHIEVEMENT GROWTH REGRESSIONS
 foreach subject in "math" "read" {
	gen temp = taks_sd_scale_min_`subject' if year == 2004
 	egen taks_`subject'_2004_all = mean(temp), by(id)
	drop temp
}

 foreach subject in "math" "read" "lang" "science" "socialstu" {
	gen temp = stanford_sd_`subject'_scale if year == 2004
 	egen stanf_`subject'_2004_all = mean(temp), by(id)
	drop temp
}



compress

***GENERATE MEASURE OF STUDENT MOBILITY
xtset id year
gen changeschools = l.campus != campus if grade >= 10 & year >= 2003 & l.campus != .
gen enterdistrict = l.campus == . if year >= 2003




*LIMIT TO 2003 AND LATER
keep if year >= 2003

*LIMIT TO GRADES 9 - 11
keep if grade >= 9 & grade <= 11
keep id campus year *taks_sd_scale_min* *stanford_sd_*_scale grade year ethnicity econdis atrisk speced lep gifted enroll* female taks_*_2004* stanf_*_2004* taks_*_2003 stanf_*_2003 changeschools enterdistrict
compress


*MERGE IN STUDENT-TEACHER LINKS
sort id campus year
merge 1:m id campus year using "C:\teacher free riding\secondary_classes.dta", keepusing(tch_number course_type course crs_title)
drop if _merge == 2


*ALLOW FOR DIFFERENT LAG VALUES BY GRADE & YEAR
foreach year of numlist 2003 2004 2007 2008 2009 {
 foreach grade of numlist 9/11 {
  foreach exam of varlist stanf_*_2004 taks_*_2004 stanf_*_2003 taks_*_2003{
    gen `exam'_y`year'_g`grade' = `exam'*(year == `year')*(grade == `grade')
  }
 }
}


*MERGE IN ASPIRE COURSE LISTS --> WORKS WELL FOR 2006-07 & LATER BUT POORLY FOR BEFORE SO WILL NEED TO USE OLD METHOD FOR PRE-PERIOD
drop _merge
sort course
merge course using "C:\teacher free riding\aspire_course_list_2009.dta", keep(subject)
replace subject = "" if year <= 2005
replace course_type = "" if year >= 2006
replace course_type = "eng" if subject == "Language Arts" & year >= 2006
replace course_type = "read" if subject == "Reading" & year >= 2006
replace course_type = "math" if subject == "Math" & year >= 2006
replace course_type = "sci" if subject == "Science" & year >= 2006
replace course_type = "soc" if subject == "Social Studies" & year >= 2006
drop if course_type == ""

gen course_type_a = course_type
replace course_type_a = "eng/read" if course_type == "eng"
replace course_type_a = "eng/read" if course_type == "read"

*MERGE IN TEACHER PREPS AND INDICATOR FOR BEING AN ASPIRE COURSE - LIMIT TO ASPIRE COURSES
sort tch_number campus year  crs_title
cap drop _merge
merge tch_number campus year  crs_title using teacher_preps.dta, keep(aspire_course teacher_preps)
tab aspire_course, missing
keep if aspire_course == 1



***MERGE IN TEACHER PERCENTAGE DATA
sort campus year grade course_type_a tch_number
drop _merge
merge campus year grade course_type_a tch_number using grade_percentages.dta
drop if _merge == 2

*DROP TEACHERS WITH FEWER THAN 10 STUDENTS
drop if students < 10

*MERGE IN DEPARTMENT SIZE
drop _merge
sort campus year grade
merge campus year grade using grade_departments.dta
drop if _merge == 2

/*
***OPTION TO MERGE IN SCHOOL LEVEL PERCENTAGES AND DEPT SIZES FOR 2006-07
sort campus year course_type tch_number
drop _merge
replace share_students = . if year == 2006
merge m:1 campus year course_type tch_number using school_percentages.dta, update keepusing(share_students)
drop if _merge == 2

sort campus year
drop _merge
merge campus year using "C:\teacher free riding\school_departments.dta"
drop if _merge == 2
foreach subject in "eng" "math" "read" "sci" "soc" {
   replace teachers_grade_`subject' = teachers_school_`subject' if year == 2006
}
*/

*MERGE IN TEACHER ID LINKED OVER TIME DERIVED FROM NAMES (CONDITIONAL ON BEING IN HISD IN 2006-07 OR LATER)
*NOTE THAT ONLY A SUBSET OF TEACHERS CAN BE LINKED BACK BEFORE 2006-07
destring tch_number, replace
drop _merge

**PRE -2006
save temp, replace
keep if year <= 2005
sort tch_number campus year 
merge m:1 tch_number campus year using teacher_linked_ids_pre
drop if _merge == 2
drop _merge
save temp1, replace

*POST - 2006
use temp, clear
keep if year >= 2006
sort tch_number
merge m:1 tch_number using teacher_linked_ids_post
drop if _merge == 2
drop _merge
append using temp1


*HISD HAD AN EXPERIMENTAL PROGRAM IN 2005-06 THAT WAS BASED ON INDIVIDUAL REWARDS, HENCE WE'LL DROP THIS YEAR
drop if year == 2005

*2006 IS BASED ON CAMPUS-WIDE DEPARTMENTAL AWARDS RATHER THAN GRADE LEVEL, SO DROP THIS YEAR TOO
drop if year == 2006

***ASSIGN WEIGHTS SO THAT EACH STUDENT HAS A VALUE OF 1 IN EACH SUBJECT
duplicates tag id year campus course_type, gen(classes_in_subject)
replace classes_in_subject = classes_in_subject + 1
gen weight = 1/classes_in_subject
drop if id == .



**GENERATE POST INDICATORS
gen post = year >= 2006
gen post_share_students = post*share_students
foreach var of varlist teachers_grade_* {
	gen post_`var' = post*`var'
}
gen school_year = campus*10000 + year

*GENERATE VARIABLES THAT POOL TAKS(10TH/11TH) AND STANFORD(9TH) FOR SCI AND SOC
	gen stanf_taks_soc = stanford_sd_socialstu_scale if grade == 9
	replace stanf_taks_soc = taks_sd_scale_min_soc if grade >= 10
	gen lstanford_sd_socialstu_scale_9 = lstanford_sd_socialstu_scale*(grade == 9)
	gen lstanford_sd_socialstu_scale_10 = lstanford_sd_socialstu_scale*(grade >= 10)


	gen stanf_taks_sci = stanford_sd_science_scale if grade == 9
	replace stanf_taks_sci = taks_sd_scale_min_sci if grade >= 10
	gen lstanford_sd_science_scale_9 = lstanford_sd_science_scale*(grade == 9)
	gen lstanford_sd_science_scale_10 = lstanford_sd_science_scale*(grade >= 10)

	
cap rm teachers_share_bal.txt
cap rm teachers_share_bal.xml


	gen white = ethnicity == 5
	gen black = ethnicity == 3
	gen hisp = ethnicity == 4
	gen econ_disadv = econdis == 1 | econdis == 2 | econdis == 99


   *IF BEFORE 2006-07, USE ONLY TEACHERS WITH NEW ID PROVIDED IN 2006-07
	xi i.grade*i.year, prefix(_g)

	*DROP TEACHERS WHO HAVE MORE THAN 90% SPECIAL EDUCATION or LEPSTUDENTS
	egen spec_ed_share = mean(speced), by(tch_number campus grade year subject)
	egen lep_share = mean(lep), by(tch_number campus grade year subject)
	drop if spec_ed_share > .8
	drop if lep_share > .8
	

**BALANCE TESTS****
	
	foreach outcome of varlist female white black hisp {

	***MATH --> TAKS MATH
	areg `outcome' post_share_students share_students post _g*  enroll* if regular_hs == 1 & course_type == "math" & taks_sd_scale_min_math != . & taks_math_2004 != . [pw = weight], cluster(campus) absorb(school_year)
	outreg2 post_share_students share_students using teachers_share_bal, excel dec(3) nocons ctitle("Math, `outcome'")
	
    
	***ENGLISH --> STANFORD LANGUAGE***
	areg `outcome'  post_share_students share_students  post   _g* enroll* if regular_hs == 1 & course_type == "eng" & stanford_sd_lang_scale != . & stanf_lang_2004 != . [pw = weight], cluster(campus) absorb(school_year)
	outreg2 post_share_students share_students using teachers_share_bal, excel dec(3) nocons ctitle("Eng, `outcome'")
	
  
	***	SCIENCE POOLED
	areg  `outcome'  post_share_students share_students  post   _g* enroll*   if  regular_hs == 1 &  course_type == "sci" & stanf_taks_sci != . & stanf_science_2004 != .  [pw = weight], cluster(campus) absorb(school_year)
	outreg2 post_share_students share_students using teachers_share_bal, excel dec(3) nocons ctitle("Sci, `outcome'")

  
	***SOC POOLED
	areg  `outcome' post_share_students share_students post   _g* enroll*   if  regular_hs == 1  & course_type == "soc" & stanf_taks_soc != . & stanf_socialstu_2004 != . [pw = weight], cluster(campus) absorb(school_year)
	outreg2 post_share_students share_students using teachers_share_bal, excel dec(3) nocons ctitle("Soc, `outcome'")

	}
	
	foreach outcome of varlist econ_disadv  {

	***MATH --> TAKS MATH
	areg `outcome' post_share_students share_students post  _g* enroll*  if regular_hs == 1 & course_type == "math" & taks_sd_scale_min_math != . & taks_math_2004 != . [pw = weight], cluster(campus) absorb(school_year)
	outreg2 post_share_students share_students using teachers_share_bal, excel dec(3) nocons ctitle("Math, `outcome'")
	
    
	***ENGLISH --> STANFORD LANGUAGE***
	areg `outcome'  post_share_students share_students  post   _g* enroll*  if regular_hs == 1 & course_type == "eng" & stanford_sd_lang_scale != . & stanf_lang_2004 != . [pw = weight], cluster(campus) absorb(school_year)
	outreg2 post_share_students share_students using teachers_share_bal, excel dec(3) nocons ctitle("Eng, `outcome'")
	
  
	***	SCIENCE POOLED
	areg  `outcome'  post_share_students share_students  post      _g* enroll*  if   regular_hs == 1 &  course_type == "sci" & stanf_taks_sci != . & stanf_science_2004 != .  [pw = weight], cluster(campus) absorb(school_year)
	outreg2 post_share_students share_students using teachers_share_bal, excel dec(3) nocons ctitle("Sci, `outcome'")

  
	***SOC POOLED
	areg  `outcome' post_share_students share_students post   _g* enroll*   if  regular_hs == 1  & course_type == "soc" & stanf_taks_soc != . & stanf_socialstu_2004 != . [pw = weight], cluster(campus) absorb(school_year)
	outreg2 post_share_students share_students using teachers_share_bal, excel dec(3) nocons ctitle("Soc, `outcome'")

	}
	
	foreach outcome of varlist atrisk   {

	***MATH --> TAKS MATH
	areg `outcome' post_share_students share_students post  _g* enroll*  if regular_hs == 1 & course_type == "math" & taks_sd_scale_min_math != . & taks_math_2004 != . [pw = weight], cluster(campus) absorb(school_year)
	outreg2 post_share_students share_students using teachers_share_bal, excel dec(3) nocons ctitle("Math, `outcome'")
	
    
	***ENGLISH --> STANFORD LANGUAGE***
	areg `outcome'  post_share_students share_students  post   _g* enroll*  if regular_hs == 1 & course_type == "eng" & stanford_sd_lang_scale != . & stanf_lang_2004 != . [pw = weight], cluster(campus) absorb(school_year)
	outreg2 post_share_students share_students using teachers_share_bal, excel dec(3) nocons ctitle("Eng, `outcome'")
	
  
	***	SCIENCE POOLED
	areg  `outcome'  post_share_students share_students  post      _g* enroll*    if  regular_hs == 1 &  course_type == "sci" & stanf_taks_sci != . & stanf_science_2004 != .  [pw = weight], cluster(campus) absorb(school_year)
	outreg2 post_share_students share_students using teachers_share_bal, excel dec(3) nocons ctitle("Sci, `outcome'")

  
	***SOC POOLED
	areg  `outcome' post_share_students share_students post   _g* enroll*   if  regular_hs == 1  & course_type == "soc" & stanf_taks_soc != . & stanf_socialstu_2004 != . [pw = weight], cluster(campus) absorb(school_year)
	outreg2 post_share_students share_students using teachers_share_bal, excel dec(3) nocons ctitle("Soc, `outcome'")

	}
	
	foreach outcome of varlist  speced   {

	***MATH --> TAKS MATH
	areg `outcome' post_share_students share_students post  _g* enroll*  if regular_hs == 1 & course_type == "math" & taks_sd_scale_min_math != . & taks_math_2004 != . [pw = weight], cluster(campus) absorb(school_year)
	outreg2 post_share_students share_students using teachers_share_bal, excel dec(3) nocons ctitle("Math, `outcome'")
	
    
	***ENGLISH --> STANFORD LANGUAGE***
	areg `outcome'  post_share_students share_students  post   _g* enroll*  if regular_hs == 1 & course_type == "eng" & stanford_sd_lang_scale != . & stanf_lang_2004 != . [pw = weight], cluster(campus) absorb(school_year)
	outreg2 post_share_students share_students using teachers_share_bal, excel dec(3) nocons ctitle("Eng, `outcome'")
	
  
	***	SCIENCE POOLED
	areg  `outcome'  post_share_students share_students  post   _g* enroll*   if  regular_hs == 1 &  course_type == "sci" & stanf_taks_sci != . & stanf_science_2004 != .  [pw = weight], cluster(campus) absorb(school_year)
	outreg2 post_share_students share_students using teachers_share_bal, excel dec(3) nocons ctitle("Sci, `outcome'")

  
	***SOC POOLED
	areg  `outcome' post_share_students share_students post   _g* enroll*   if  regular_hs == 1  & course_type == "soc" & stanf_taks_soc != . & stanf_socialstu_2004 != . [pw = weight], cluster(campus) absorb(school_year)
	outreg2 post_share_students share_students using teachers_share_bal, excel dec(3) nocons ctitle("Soc, `outcome'")

	}


	foreach outcome of varlist lep    {

	***MATH --> TAKS MATH
	areg `outcome' post_share_students share_students post  _g* enroll*  if regular_hs == 1 & course_type == "math" & taks_sd_scale_min_math != . & taks_math_2004 != . [pw = weight], cluster(campus) absorb(school_year)
	outreg2 post_share_students share_students using teachers_share_bal, excel dec(3) nocons ctitle("Math, `outcome'")
	
    
	***ENGLISH --> STANFORD LANGUAGE***
	areg `outcome'  post_share_students share_students  post   _g* enroll*  if regular_hs == 1 & course_type == "eng" & stanford_sd_lang_scale != . & stanf_lang_2004 != . [pw = weight], cluster(campus) absorb(school_year)
	outreg2 post_share_students share_students using teachers_share_bal, excel dec(3) nocons ctitle("Eng, `outcome'")
	
  
	***	SCIENCE POOLED
	areg  `outcome'  post_share_students share_students  post   _g* enroll*   if  regular_hs == 1 &  course_type == "sci" & stanf_taks_sci != . & stanf_science_2004 != .  [pw = weight], cluster(campus) absorb(school_year)
	outreg2 post_share_students share_students using teachers_share_bal, excel dec(3) nocons ctitle("Sci, `outcome'")

  
	***SOC POOLED
	areg  `outcome' post_share_students share_students post   _g* enroll*   if  regular_hs == 1  & course_type == "soc" & stanf_taks_soc != . & stanf_socialstu_2004 != . [pw = weight], cluster(campus) absorb(school_year)
	outreg2 post_share_students share_students using teachers_share_bal, excel dec(3) nocons ctitle("Soc, `outcome'")

	}
	
	foreach outcome of varlist gifted   {

	***MATH --> TAKS MATH
	areg `outcome' post_share_students share_students post  _g* enroll*  if regular_hs == 1 & course_type == "math" & taks_sd_scale_min_math != . & taks_math_2004 != . [pw = weight], cluster(campus) absorb(school_year)
	outreg2 post_share_students share_students using teachers_share_bal, excel dec(3) nocons ctitle("Math, `outcome'")
	
    
	***ENGLISH --> STANFORD LANGUAGE***
	areg `outcome'  post_share_students share_students  post   _g* enroll*  if regular_hs == 1 & course_type == "eng" & stanford_sd_lang_scale != . & stanf_lang_2004 != . [pw = weight], cluster(campus) absorb(school_year)
	outreg2 post_share_students share_students using teachers_share_bal, excel dec(3) nocons ctitle("Eng, `outcome'")
	
  
	***	SCIENCE POOLED
	areg  `outcome'  post_share_students share_students  post      _g* enroll*   if  regular_hs == 1 &  course_type == "sci" & stanf_taks_sci != . & stanf_science_2004 != .  [pw = weight], cluster(campus) absorb(school_year)
	outreg2 post_share_students share_students using teachers_share_bal, excel dec(3) nocons ctitle("Sci, `outcome'")

  
	***SOC POOLED
	areg  `outcome' post_share_students share_students post   _g* enroll*    if regular_hs == 1  & course_type == "soc" & stanf_taks_soc != . & stanf_socialstu_2004 != . [pw = weight], cluster(campus) absorb(school_year)
	outreg2 post_share_students share_students using teachers_share_bal, excel dec(3) nocons ctitle("Soc, `outcome'")

	}
	
	
	**ACHIEVEMENT
	
	
	***MATH --> TAKS MATH
	areg taks_math_2004_all post_share_students share_students post  _g* enroll*  if regular_hs == 1 & course_type == "math" & taks_sd_scale_min_math != . & taks_math_2004 != . [pw = weight], cluster(campus) absorb(school_year)
	outreg2 post_share_students share_students using teachers_share_bal, excel dec(3) nocons ctitle("Math, taks_math_2004, level")
	
    ***MATH --> Stanford MATH
	areg stanf_math_2004_all post_share_students share_students post  _g* enroll*  if regular_hs == 1 & course_type == "math" & taks_sd_scale_min_math != . & stanf_math_2004 != . [pw = weight], cluster(campus) absorb(school_year)
	outreg2 post_share_students share_students using teachers_share_bal, excel dec(3) nocons ctitle("Math, stanf_math_2004, level")
	
	***ENGLISH --> STANFORD LANGUAGE***
	areg stanf_lang_2004_all  post_share_students share_students  post   _g* enroll*  if regular_hs == 1 & course_type == "eng" & stanford_sd_lang_scale != . & stanf_lang_2004 != . [pw = weight], cluster(campus) absorb(school_year)
	outreg2 post_share_students share_students using teachers_share_bal, excel dec(3) nocons ctitle("Eng, stanf_lang_2004, level")
	
  
	***	SCIENCE POOLED
	areg   stanf_science_2004_all post_share_students share_students  post      _g* enroll*   if  regular_hs == 1 &  course_type == "sci" & stanf_taks_sci != . & stanf_science_2004 != .  [pw = weight], cluster(campus) absorb(school_year)
	outreg2 post_share_students share_students using teachers_share_bal, excel dec(3) nocons ctitle("Sci, stanf_scienceence_2004, level")

  
	***SOC POOLED
	areg   stanf_socialstu_2004_all post_share_students share_students post   _g* enroll*    if regular_hs == 1  & course_type == "soc" & stanf_taks_soc != . & stanf_socialstu_2004 != . [pw = weight], cluster(campus) absorb(school_year)
	outreg2 post_share_students share_students using teachers_share_bal, excel dec(3) nocons ctitle("Soc, stanf_socialstuialstu_2004,level")


	
	*ACHIEVEMENT GROWTH
	
	***MATH --> TAKS MATH
	areg taks_math_2004_all post_share_students share_students post  _g* enroll* taks_math_2003_y*_g* if regular_hs == 1 & course_type == "math" & taks_sd_scale_min_math != . & taks_math_2004 != . [pw = weight], cluster(campus) absorb(school_year)
	outreg2 post_share_students share_students using teachers_share_bal, excel dec(3) nocons ctitle("Math, taks_math_2004 growth, va")
	
    ***MATH --> Stanford MATH
	areg stanf_math_2004_all post_share_students share_students post  _g* enroll* stanf_math_2003_y*_g*  if regular_hs == 1 & course_type == "math" & taks_sd_scale_min_math != . & stanf_math_2004 != .  [pw = weight], cluster(campus) absorb(school_year)
	outreg2 post_share_students share_students using teachers_share_bal, excel dec(3) nocons ctitle("Math, stanf_math_2004 growth, va")
	
	***ENGLISH --> STANFORD LANGUAGE***
	areg stanf_lang_2004_all  post_share_students share_students  post   _g* enroll* stanf_lang_2003_y*_g*  if regular_hs == 1 & course_type == "eng" & stanford_sd_lang_scale != . & stanf_lang_2004 != . [pw = weight], cluster(campus) absorb(school_year)
	outreg2 post_share_students share_students using teachers_share_bal, excel dec(3) nocons ctitle("Eng, stanf_lang_2004 growth, va")
	
  
	***	SCIENCE POOLED
	areg   stanf_science_2004_all post_share_students share_students  post  _g* enroll*  stanf_science_2003_y*_g*   if  regular_hs == 1 &  course_type == "sci" & stanf_taks_sci != . & stanf_science_2004 != .  [pw = weight], cluster(campus) absorb(school_year)
	outreg2 post_share_students share_students using teachers_share_bal, excel dec(3) nocons ctitle("Sci, stanf_scienceence_2004 growth, va")

  
	***SOC POOLED
	areg   stanf_socialstu_2004_all post_share_students share_students post   _g* enroll*  stanf_socialstu_2003_y*_g*   if regular_hs == 1  & course_type == "soc" & stanf_taks_soc != . & stanf_socialstu_2004 != . [pw = weight], cluster(campus) absorb(school_year)
	outreg2 post_share_students share_students using teachers_share_bal, excel dec(3) nocons ctitle("Soc, stanf_socialstuialstu_2004 growth, va")
	
	
	

		
	
	*CHANGING SCHOOLS (GRADES 10 & 11 ONLY)
	
	***MATH --> TAKS MATH
	areg changeschools post_share_students share_students post  _g* enroll* taks_math_2004_y*_g*  if regular_hs == 1 & course_type == "math" & taks_sd_scale_min_math != . & taks_math_2004 != .  != . [pw = weight], cluster(campus) absorb(school_year)
	outreg2 post_share_students share_students using teachers_share_bal, excel dec(3) nocons ctitle("Math, change schools,  va")
	
    ***MATH --> Stanford MATH
	areg changeschools post_share_students share_students post  _g* enroll* stanf_math_2004_y*_g*   if regular_hs == 1 & course_type == "math" & taks_sd_scale_min_math != . & stanf_math_2004 != .   != . [pw = weight], cluster(campus) absorb(school_year)
	outreg2 post_share_students share_students using teachers_share_bal, excel dec(3) nocons ctitle("Math stanf, change schools,  va")
	
	***ENGLISH --> STANFORD LANGUAGE***
	areg changeschools  post_share_students share_students  post   _g* enroll*  stanf_lang_2004_y*_g*  if regular_hs == 1 & course_type == "eng" & stanford_sd_lang_scale != . & stanf_lang_2004 != .  != . [pw = weight], cluster(campus) absorb(school_year)
	outreg2 post_share_students share_students using teachers_share_bal, excel dec(3) nocons ctitle("Eng, change schools,  va")
	
  
	***	SCIENCE POOLED
	areg   changeschools   post_share_students share_students  post  _g* enroll*   stanf_science_2004_y*_g*     if  regular_hs == 1 &  course_type == "sci" & stanf_taks_sci != . & stanf_science_2004 != .   != . [pw = weight], cluster(campus) absorb(school_year)
	outreg2 post_share_students share_students using teachers_share_bal, excel dec(3) nocons ctitle("Sci, change schools,  va")

  
	***SOC POOLED
	areg   changeschools   post_share_students share_students post   _g* enroll*  stanf_socialstu_2004_y*_g*   if regular_hs == 1  & course_type == "soc" & stanf_taks_soc != . & stanf_socialstu_2004 != .  != . [pw = weight], cluster(campus) absorb(school_year)
	outreg2 post_share_students share_students using teachers_share_bal, excel dec(3) nocons ctitle("Soc, change schools, change schools")
	
		
	
	*ENTERING DISTRICT
	
	***MATH --> TAKS MATH
	areg enterdistrict post_share_students share_students post  _g* enroll* taks_math_2004_y*_g*   if regular_hs == 1 & course_type == "math" & taks_sd_scale_min_math != . & taks_math_2004 != .  != . [pw = weight], cluster(campus) absorb(school_year)
	outreg2 post_share_students share_students using teachers_share_bal, excel dec(3) nocons ctitle("Math,  enter district,  va")
	
    ***MATH --> Stanford MATH
	areg enterdistrict post_share_students share_students post  _g* enroll* taks_math_2004_y*_g*   if regular_hs == 1 & course_type == "math" & taks_sd_scale_min_math != . & stanf_math_2004 != .   != . [pw = weight], cluster(campus) absorb(school_year)
	outreg2 post_share_students share_students using teachers_share_bal, excel dec(3) nocons ctitle("Math stanf,  enter district,   va")
	
	***ENGLISH --> STANFORD LANGUAGE***
	areg enterdistrict  post_share_students share_students  post   _g* enroll* taks_math_2004_y*_g*   if regular_hs == 1 & course_type == "eng" & stanford_sd_lang_scale != . & stanf_lang_2004 != .  != . [pw = weight], cluster(campus) absorb(school_year)
	outreg2 post_share_students share_students using teachers_share_bal, excel dec(3) nocons ctitle("Eng,  enter district,   va")
	
  
	***	SCIENCE POOLED
	areg   enterdistrict   post_share_students share_students  post  _g* enroll* taks_math_2004_y*_g*   if  regular_hs == 1 &  course_type == "sci" & stanf_taks_sci != . & stanf_science_2004 != .   != . [pw = weight], cluster(campus) absorb(school_year)
	outreg2 post_share_students share_students using teachers_share_bal, excel dec(3) nocons ctitle("Sci,  enter district,   va")

  
	***SOC POOLED
	areg   enterdistrict   post_share_students share_students post   _g* enroll* taks_math_2004_y*_g*    if regular_hs == 1  & course_type == "soc" & stanf_taks_soc != . & stanf_socialstu_2004 != .  != . [pw = weight], cluster(campus) absorb(school_year)
	outreg2 post_share_students share_students using teachers_share_bal, excel dec(3) nocons ctitle("Soc,  enter district, va")
	
	
*CHECK TEACHER PREPS

	***MATH --> TAKS MATH
	areg teacher_preps post_share_students  share_students  post taks_math_2004_y*_g* _I* _g* enroll* if regular_hs == 1  & course_type == "math" &  taks_sd_scale_min_math != . [pw = weight], cluster(campus) absorb(school_year)
	outreg2 post_share_students  share_students   using teachers_share_bal, excel dec(3) nocons ctitle("Math, teacher_preps, teacher_preps")

	***ENGLISH --> STANFORD LANGUAGE***
	areg teacher_preps  post_share_students  share_students   post  stanf_lang_2004_y*_g* _I* _g* enroll* if regular_hs == 1  & course_type == "eng" & stanford_sd_lang_scale != . [pw = weight], cluster(campus) absorb(school_year)
	outreg2 post_share_students  share_students   using teachers_share_bal, excel dec(3) nocons ctitle("Eng, teacher_preps, teacher_preps")

	***SCIENCE  - CONTROL FOR LAGGED STANFORD INSTEAD OF TAKS AS LAGGED TAKS IS NOT AVAILABLE FOR MANY 10TH GRADERS	
	areg  teacher_preps  post_share_students  share_students    post stanf_science_2004_y*_g* _I* _g* enroll* if regular_hs == 1 &  course_type == "sci" & stanf_taks_sci != . [pw = weight], cluster(campus) absorb(school_year)
	outreg2 post_share_students  share_students   using teachers_share_bal, excel dec(3) nocons ctitle("Sci, teacher_preps, teacher_preps")

	***SOC
	areg  teacher_preps post_share_students  share_students   post stanf_socialstu_2004_y*_g* _I* _g* enroll* if regular_hs == 1  & course_type == "soc" & stanf_taks_soc != . [pw = weight], cluster(campus) absorb(school_year)
	outreg2 post_share_students  share_students   using teachers_share_bal, excel dec(3) nocons ctitle("Soc, teacher_preps, teacher_preps")
	
	***MATH - STANF
	areg teacher_preps post_share_students  share_students  _I* _g* enroll* stanf_math_2004_y*_g*  if regular_hs == 1 &  course_type == "math" & stanford_sd_math_scale != .  [pw = weight] , cluster(campus) absorb(school_year)
	outreg2 post_share_students  share_students   using teachers_share_bal, excel dec(3) nocons ctitle("Math - teacher_preps , teacher_preps")

		
				
		

	
